<?php
$contacts = array();

// Group
$sql = "SELECT friend_group_id, name FROM friend_group";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
	$contacts[] = sprintf('"%s" [%d:Group]', $row['name'], $row['friend_group_id']);
}

// Friend
$sql = "SELECT friend_id, fullname, mail FROM friend";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
	$contacts[] = sprintf('"%s" [%d:Friend:%s]', $row['fullname'], $row['friend_id'], $row['mail']);
}